#include<bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
const int mod=998244353,inf=0x3f3f3f3f3f3f3f3f;
const int N=1e6+10,M=2e5+10;
int n,m;
vector<char>ch[N],vis[N];
int xx[4]={0,1,0,-1},yy[4]={1,0,-1,0}; 
void update(int x,int y)
{
	ch[x][y]='1';
	vis[x][y]=1;
	for ( int i = 0 ; i < 4 ; i++ )vis[x+xx[i]][y+yy[i]]=1;
}
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	freopen("indian.in","r",stdin);
	freopen("indian.out","w",stdout);
	cin >> n >> m;
	ch[0].resize(m+2),ch[n+1].resize(m+2);
	vis[0].resize(m+2),vis[n+1].resize(m+2);
	for ( int i = 1 ; i <= n ; i++ )
	{
		ch[i].resize(m+2);
		vis[i].resize(m+2);
		for ( int j = 1 ; j <= m ; j++ )cin >> ch[i][j];
	}
	for ( int i = 1 ; i <= n ; i++ )
	{
		for ( int j = 1 ; j <= m ; j++ )
		{
			if(vis[i][j]||ch[i][j]=='.')continue;
			if(!vis[i][j+1]&&ch[i][j+1]=='#')update(i,j+1);
			else if(ch[i+1][j]=='#')update(i+1,j);
			else update(i,j);
		}
	}
	for ( int i = 1 ; i <= n ; i++ )
	{
		for ( int j = 1 ; j <= m ; j++ )
		{
			if(ch[i][j]=='#')cout << 0;
			else cout << ch[i][j];
		}
		cout << endl;
	}
	return 0;
}


